firmware_class: Log every success and failure against given device
authorBen Hutchings <ben@decadent.org.uk>
Sun, 9 Dec 2012 16:02:00 +0000 (16:02 +0000)
committerBen Hutchings <ben@decadent.org.uk>
Thu, 17 Mar 2016 01:25:23 +0000 (01:25 +0000)
The hundreds of users of request_firmware() have nearly as many
different log formats for reporting failures.  They also have only the
vaguest hint as to what went wrong; only firmware_class really knows
that.  Therefore, add specific log messages for the failure modes that
aren't currently logged.

In case of a driver that tries multiple names, this may result in the
impression that it failed to initialise.  Therefore, also log successes.

This makes many error messages in drivers redundant, which will be
removed in later patches.

This does not cover the case where we fall back to a user-mode helper
(which is no longer enabled in Debian).

NOTE: hw-detect will depend on the "firmware: failed to load %s (%d)\n"
format to detect missing firmware.

Gbp-Pq: Topic bugfix/all
Gbp-Pq: Name firmware_class-log-every-success-and-failure.patch

drivers/base/firmware_class.c

index e65f6ffdc4af752192c4ba39b38a0c89653d9580..ed6f7b7ab0bc326a5746e9e465d6b57d4f8e9810 100644 (file)
@@ -355,16 +355,19 @@ static int fw_get_filesystem_firmware(struct device *device,
                rc = fw_read_file_contents(file, buf);
                fput(file);
                if (rc)
-                       dev_warn(device, "firmware, attempted to load %s, but failed with error %d\n",
+                       dev_dbg(device, "firmware, attempted to load %s, but failed with error %d\n",
                                path, rc);
                else
                        break;
        }
        __putname(path);
 
-       if (!rc) {
-               dev_dbg(device, "firmware: direct-loading firmware %s\n",
-                       buf->fw_id);
+       if (rc) {
+               dev_err(device, "firmware: failed to load %s (%d)\n",
+                       buf->fw_id, rc);
+       } else {
+               dev_info(device, "firmware: direct-loading firmware %s\n",
+                        buf->fw_id);
                mutex_lock(&fw_lock);
                set_bit(FW_STATUS_DONE, &buf->status);
                complete_all(&buf->completion);
@@ -1046,7 +1049,8 @@ _request_firmware_prepare(struct firmware **firmware_p, const char *name,
        }
 
        if (fw_get_builtin_firmware(firmware, name)) {
-               dev_dbg(device, "firmware: using built-in firmware %s\n", name);
+               dev_info(device, "firmware: using built-in firmware %s\n",
+                        name);
                return 0; /* assigned */
        }
 
@@ -1132,7 +1136,7 @@ _request_firmware(const struct firmware **firmware_p, const char *name,
        if (opt_flags & FW_OPT_NOWAIT) {
                timeout = usermodehelper_read_lock_wait(timeout);
                if (!timeout) {
-                       dev_dbg(device, "firmware: %s loading timed out\n",
+                       dev_err(device, "firmware: %s loading timed out\n",
                                name);
                        ret = -EBUSY;
                        goto out;